cmake_minimum_required(VERSION 3.0)

project(dycore-test LANGUAGES Fortran)

set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}")

if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
  set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none -ffpe-trap=invalid,zero,overflow")
  if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0 -fcheck=all -g -fbacktrace")
  else ()
    set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Ofast -lgomp -fopenmp")
  endif ()
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
  if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -no-wrap-margin -O0 -check bounds -g -traceback")
  else ()
    set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -no-wrap-margin -O3 -qopenmp")
  endif ()
endif ()

set(sources
  src/const_mod.F90
  src/quadpack.f90
  src/adv/adv_case1_mod.F90
  src/sw/sw_case2_mod.F90
  src/sw/sw_case5_mod.F90
  src/sw/sw_case6_mod.F90
  src/sw/sw_case8_mod.F90
  src/sw/sw_case10_mod.F90
  src/nh/nh_case1_mod.F90
  src/nh/nh_case2_mod.F90
  src/nh/nh_case3_mod.F90
  src/nh/nh_case5_mod.F90
  src/nh/nh_case6_mod.F90
  src/dycore_test.F90
)

add_library(dycore_test ${sources})
